package com.lai.shop.service.impl;


import com.alibaba.cloud.context.utils.StringUtils;
import com.lai.shop.utils.PageUtils;
import com.lai.shop.utils.Query;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.lai.shop.dao.OrderItemDao;
import com.lai.shop.entity.OrderItemEntity;
import com.lai.shop.service.OrderItemService;


@Service("orderItemService")
public class OrderItemServiceImpl extends ServiceImpl<OrderItemDao, OrderItemEntity> implements OrderItemService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        QueryWrapper<OrderItemEntity> queryWrapper = new QueryWrapper<>();
        if(!StringUtils.isEmpty(key)){
            queryWrapper.eq("id",key)
                    .or().eq("order_id",key)
                    .or().eq("order_sn",key);
        }
        IPage<OrderItemEntity> page = this.page(
                new Query<OrderItemEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}
